package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.BlockManagement;
import com.zygh.interactiveplatform.module.entity.BlockManagement;
import com.zygh.interactiveplatform.module.service.BlockManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-02-03
 */
@RestController
@RequestMapping("/block-management")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_BLOCKMANAGEMENT})
public class BlockManagementController {
    @Resource
    private BlockManagementService blockManagementService;

    @ApiOperation(value = "屏蔽管理新增", notes = "屏蔽管理新增")
    @PostMapping("addBlockManagemente")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_BLOCKMANAGEMENT, content = "屏蔽管理新增")
    public ResponseDTO addBlockManagemente(@RequestBody @Valid BlockManagement blockManagement) {
        return blockManagementService.addBlockManagement(blockManagement);
    }
    @ApiOperation(value = "屏蔽管理修改", notes = "屏蔽管理修改")
    @PostMapping("updateBlockManagement")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_BLOCKMANAGEMENT, content = "屏蔽管理修改")
    public ResponseDTO updateBlockManagement(@RequestBody @Valid BlockManagement blockManagement) {
        return blockManagementService.updateBlockManagement(blockManagement);
    }
    @ApiOperation(value = "屏蔽管理删除", notes = "屏蔽管理删除")
    @PostMapping("deleteBlockManagement")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_BLOCKMANAGEMENT, content = "屏蔽管理删除")
    public ResponseDTO deleteBlockManagement(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return blockManagementService.deleteBlockManagement(new_id);
    }
    @ApiOperation(value = "查询所有屏蔽管理", notes = "查询所有屏蔽管理")
    @GetMapping("findBlockManagementAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_BLOCKMANAGEMENT, content = "查询所有屏蔽管理")
    public ResponseDTO findBlockManagementAll(Integer current, Integer size) {
        return blockManagementService.findBlockManagementAll(current,size);
    }
}
